﻿<?xml version="1.0" encoding="utf-8"?>
<cms:formdefinition xmlns="http://www.composite.net/ns/management/bindingforms/std.ui.controls.lib/1.0" xmlns:internal="http://www.composite.net/ns/management/bindingforms/internal.ui.controls.lib/1.0" xmlns:f="http://www.composite.net/ns/management/bindingforms/std.function.lib/1.0" xmlns:cms="http://www.composite.net/ns/management/bindingforms/1.0">
  <cms:bindings>
    <cms:binding name="SqlQuery" type="Composite.Data.Types.ISqlFunctionInfo, Composite" />
    <cms:binding name="ParameterTypeOptions" type="System.Collections.Generic.IEnumerable`1[[System.Type]]" />
    <cms:binding name="PreviewEventHandler" type="System.EventHandler" optional="false" />

    <cms:binding name="SessionStateProvider" type="System.String" />
	<cms:binding name="SessionStateId" type="System.Guid" />
  </cms:bindings>
  <cms:layout iconhandle="sql-based-function">
    <TabPanels PreSelectedIndex="2">
      <TabPanels.Label>
        <cms:read source="SqlQuery.Name" />
      </TabPanels.Label>
      <PlaceHolder Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelSettings}">
        <FieldGroup Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelNamingAndDescription}">
          <TextBox Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelName}" Help="${Composite.Plugins.SqlFunction, EditSqlFunction.HelpName}" Type="ProgrammingIdentifier">
            <TextBox.Text>
              <cms:bind source="SqlQuery.Name" />
            </TextBox.Text>
          </TextBox>
          <TextBox Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelNamespace}" Help="${Composite.Plugins.SqlFunction, EditSqlFunction.HelpNamespace}" Type="ProgrammingNamespace">
            <TextBox.Text>
              <cms:bind source="SqlQuery.Namespace" />
            </TextBox.Text>
          </TextBox>
          <TextArea Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelDescription}" Help="${Composite.Plugins.SqlFunction, EditSqlFunction.HelpDescription}">
            <TextArea.Text>
              <cms:bind source="SqlQuery.Description" />
            </TextArea.Text>
          </TextArea>
        </FieldGroup>
        <FieldGroup Label="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelCommandBehaviour}">
          <CheckBox Label="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelIsStoredProcedure}" ItemLabel="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelIsStoredProcedureCheckBox}">
            <CheckBox.Checked>
              <cms:bind source="SqlQuery.IsStoredProcedure" />
            </CheckBox.Checked>
          </CheckBox>
          <CheckBox Label="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelReturnsXml}" ItemLabel="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelReturnsXmlCheckBox}">
            <CheckBox.Checked>
              <cms:bind source="SqlQuery.ReturnsXml" />
            </CheckBox.Checked>
          </CheckBox>
          <CheckBox Label="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelIsQuery}" ItemLabel="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelIsQueryCheckBox}">
            <CheckBox.Checked>
              <cms:bind source="SqlQuery.IsQuery" />
            </CheckBox.Checked>
          </CheckBox>
        </FieldGroup>
      </PlaceHolder>
      <internal:ParameterDesigner Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelInputParameters}">
		  <internal:ParameterDesigner.SessionStateProvider>
			  <cms:read source="SessionStateProvider"/>
		  </internal:ParameterDesigner.SessionStateProvider>
		  <internal:ParameterDesigner.SessionStateId>
			  <cms:read source="SessionStateId"/>
		  </internal:ParameterDesigner.SessionStateId>
      </internal:ParameterDesigner>
      <SqlEditor Label="${Composite.Plugins.SqlFunction, AddEditSqlFunction.LabelSqlEditor}">
        <cms:bind source="SqlQuery.Command" />
      </SqlEditor>
      <f:NullCheck>
        <f:NullCheck.CheckValue>
          <cms:read source="PreviewEventHandler" />
        </f:NullCheck.CheckValue>
        <f:NullCheck.WhenNotNull>
          <internal:PreviewPanel Label="${Composite.Plugins.SqlFunction, EditSqlFunction.LabelPreview}">
            <internal:PreviewPanel.ClickEventHandler>
              <cms:read source="PreviewEventHandler" />
            </internal:PreviewPanel.ClickEventHandler>
          </internal:PreviewPanel>
        </f:NullCheck.WhenNotNull>
      </f:NullCheck>
    </TabPanels>
  </cms:layout>
</cms:formdefinition>